package logic

import (
	"context"
	"video-system/model/mysql"

	"video-system/userrpc/internal/svc"
	"video-system/userrpc/userrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type VideoCountLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewVideoCountLogic(ctx context.Context, svcCtx *svc.ServiceContext) *VideoCountLogic {
	return &VideoCountLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 详情播放量统计
func (l *VideoCountLogic) VideoCount(in *userrpc.VideoCountRequest) (*userrpc.VideoCountResponse, error) {
	// todo: add your logic here and delete this line

	var show mysql.VideoInfo

	count := show.VideoCount(mysql.DB, in.VideoId)

	return &userrpc.VideoCountResponse{
		UploadUserId:  count.UploadUserId,
		VideoTitle:    count.VideoTitle,
		VideoCategory: count.VideoCategory,
		VideoLink:     count.VideoLink,
		CoverLink:     count.CoverLink,
		VideoIntro:    count.VideoIntro,
		PlayNum:       count.PlayNum,
		LikeNum:       count.LikeNum,
		CollectNum:    count.CollectNum,
		CommentNum:    count.CommentNum,
		VideoStatus:   count.VideoStatus,
		TopicId:       count.TopicId,
	}, nil
}
